/*Authors: Odd-Arild (first two, and last functions),
 *         Laura (last two functions)
 * 
 * */

$('input#diseaseButton').on('click', function() {
    var query = $('input#searchField').val();
    if ($.trim(query) !== '') {
        $.post("search", {
            search_val: query,
            action: "Search Diseases"
        },
        function(data) {
            $('div#result').html(data);
        });
    show();
    }
    return false;
});

$('input#symptomButton').on('click', function() {
    var query = $('input#searchField').val();
    if ($.trim(query) !== '') {
        $.post("search", {
            search_val: query,
            action: "Search Symptoms"
        },
        function(data) {
            $('div#result').html(data);
        });
    show();
    }
    return false;
});

$(function() {
    $('#slideshow img:gt(0)').hide();
    setInterval(function() {
        $('#slideshow :first-child').fadeOut()
                .next('img').fadeIn()
                .end().appendTo('#slideshow');
    },
            6000);
});

function show() {
    document.getElementById("doctorButton").style.visibility="visible";
}